<div class="content-section introduction">
    <div class="feature-intro">
        <h1>InputSwitch</h1>
        <p>InputSwitch is used to select a boolean value.</p>
    </div>
    <app-demoActions github="inputswitch" stackblitz="inputswitch-demo"></app-demoActions>
</div>

<div class="content-section implementation">
    <div class="card">
        <h5>Basic</h5>
        <p-inputSwitch [(ngModel)]="checked1"></p-inputSwitch>

        <h5>PreSelection</h5>
        <p-inputSwitch [(ngModel)]="checked2"></p-inputSwitch>
    </div>
</div>

<div class="content-section documentation">
    <p-tabView>
        <p-tabPanel header="Documentation">
            <h5>Import</h5>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;InputSwitchModule&#125; from 'primeng/inputswitch';
</app-code>

            <h5>Getting Started</h5>
            <p>Two-way binding to a boolean property is defined using the standard ngModel directive.</p>

<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-inputSwitch [(ngModel)]="checked"&gt;&lt;/p-inputSwitch&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class ModelComponent &#123;

    checked: boolean;

&#125;
</app-code>

            <p>As model is two-way binding enabled, setting the bound value as true displays the state as checked by default.</p>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class ModelComponent &#123;

   checked: boolean = true;

&#125;
</app-code>

            <h5>Model Driven Forms</h5>
            <p>InputSwitch can be used in a model driven form as well.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-inputSwitch formControlName="enabled"&gt;&lt;/p-inputSwitch&gt;
</app-code>

            <h5>Properties</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                          <td>tabindex</td>
                          <td>number</td>
                          <td>null</td>
                          <td>Index of the element in tabbing order.</td>
                        </tr>
                        <tr>
                            <td>inputId</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Identifier of the input element.</td>
                        </tr>
                        <tr>
                            <td>name</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Name of the input element.</td>
                        </tr>
                        <tr>
                            <td>ariaLabelledBy</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Establishes relationships between the component and label(s) where its value should be one or more element IDs.</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the element should be disabled.</td>
                        </tr>
                        <tr>
                            <td>readonly</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the component cannot be edited.</td>
                        </tr>
                        <tr>
                            <td>trueValue</td>
                            <td>any</td>
                            <td>null</td>
                            <td>Value in checked state.</td>
                        </tr>
                        <tr>
                            <td>falseValue</td>
                            <td>any</td>
                            <td>null</td>
                            <td>Value in unchecked state.</td>
                        </tr>
                        <tr>
                            <td>ariaLabel</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Used to define a string that autocomplete attribute the current element.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Events</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Parameters</th>
                        <th>Description</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>onChange</td>
                        <td>event.originalEvent: browser event<br>
                            event.checked: checked state as a boolean</td>
                        <td>Callback to invoke on state change.</td>
                    </tr>
                    </tbody>
                </table>
            </div>

<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-inputSwitch (onChange)="handleChange($event)" [(ngModel)]="val"&gt;&lt;/p-inputSwitch&gt;
</app-code>
 <app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class ModelComponent &#123;

    handleChange(e) &#123;
        let isChecked = e.checked;
    &#125;
&#125;
</app-code>

            <h5>Styling</h5>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>p-inputswitch</td>
                            <td>Container element.</td>
                        </tr>
                        <tr>
                            <td>p-inputswitch-checked</td>
                            <td>Container element in active state.</td>
                        </tr>
                        <tr>
                            <td>p-inputswitch-slider</td>
                            <td>Slider element behind the handle.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Dependencies</h5>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/inputswitch" class="btn-viewsource" target="_blank">
                <span>View on GitHub</span>
            </a>
            <a href="https://stackblitz.com/edit/primeng-inputswitch-demo" class="btn-viewsource" style="margin-left: .5em;" target="_blank">
                <span>Edit in StackBlitz</span>
            </a>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;h5&gt;Basic&lt;/h5&gt;
&lt;p-inputSwitch [(ngModel)]="checked1"&gt;&lt;/p-inputSwitch&gt;

&lt;h5&gt;Preselection&lt;/h5&gt;
&lt;p-inputSwitch [(ngModel)]="checked2"&gt;&lt;/p-inputSwitch&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class InputSwitchDemo &#123;

    checked1: boolean = false;

    checked2: boolean = true;
&#125;
</app-code>
        </p-tabPanel>
        <p-tabPanel header="StackBlitz">
            <ng-template pTemplate="content">
                <iframe src="https://stackblitz.com/edit/primeng-inputswitch-demo?embed=1" style="width: 100%; height: 768px; border: none;"></iframe>
            </ng-template>
        </p-tabPanel>
    </p-tabView>
</div>
